
#ifndef _DEFS_H_
#define _DEFS_H_

#if defined(_MSC_VER) && (_MSC_VER >= 1600)    
#pragma execution_character_set("utf-8")    
#endif

#define myPi 3.141592654

#if defined(APPVER)
#undef APPVER
#else 
#define APPVER "version 1.0.1"
#endif
/*GET*/
#if defined(myApp)
#undef myApp
#else 
#define myApp (static_cast<NSApplication::Application*>(qApp))
#endif
/*GET*/
#if defined(myManager)
#undef myManager
#else 
#define myManager(_name_) myApp-> \
getManager<NSApplication::##_name_>(#_name_)
#endif
/*GET*/
#if defined(myOperation)
#undef myOperation
#else 
#define myOperation(_name_) myManager(OperationsManager)->\
getOperation<NSOperation::##_name_>(#_name_)
#endif
/*GET*/
#if defined(myWidget)
#undef myWidget
#else 
#define myWidget(_name_) myManager(WidgetsManager)->\
getWidget<NSWidgets::##_name_>(#_name_)
#endif

/*GET*/
#if defined(myVtk)
#undef myVtk
#else 
#define myVtk(_id_) dynamic_cast<NSWidgets::VtkWidget*>(myWidget(CentralTabWidget)->getTabWiget(_id_));
#endif

#ifndef Sp
#define Sp(_C_) vtkSmartPointer<_C_>
#endif // !Sp
//�ļ���ȡ�߳�
#if defined(taskThread)
#undef taskThread
#else 
#include <QThreadPool>
#define taskThread(_name_, _file_, _this_, _callback_, _progress_)\
NSExchange::##_name_##Task* _task = new NSExchange::##_name_##Task(0, _file_); \
QObject::connect(_task, &NSExchange::##_name_##Task::actionProgressChanged, _progress_, &QProgressDialog::setValue);\
QObject::connect(_task, &NSExchange::##_name_##Task::actionReadFinished, this, _callback_);\
QThreadPool::globalInstance()->start(_task);
#endif
//����
#ifndef DECSINGLETON
#define DECSINGLETON(_CLASS_, ...)					\
	private:																\
		static _CLASS_* m_ins ;								\
		_CLASS_() :##__VA_ARGS__ { Initialize(); }	\
		~_CLASS_() { Finalize(); }								\
	public:																\
		static _CLASS_* getInstance() {					\
			if (m_ins == nullptr)								\
				m_ins = new _CLASS_;							\
			return m_ins;											\
		}
#endif 
//ͳһ���ųߴ�
#ifndef _S
#include <windows.h>
#define _S(_R_)  (int)(_R_*((double)GetSystemMetrics(SM_CXSCREEN) / 1920.0))
#endif // !_S
#endif 
//�����ļ�·��
#ifndef INI_PATH
const int MAX_FILES = 10;
#include <QStandardPaths>
#define INI_PATH QString("%1/configs.ini").arg(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))
#endif 


#ifndef executeCommandBegin
#include <QString>
typedef QString PY_CODE;
#define executeCommandBegin(_Commd_, ...)																			\
NSCommands::_Commd_* _execute_cmd_ = new NSCommands::_Commd_(__VA_ARGS__);		\
PY_CODE _code_;																															\
_code_.append(
#endif // !executeCommandBegin


#ifndef executeCommandEnd
#define executeCommandEnd													\
);																									\
_execute_cmd_->setUndoDoc(_code_); \
myManager(CommandsManager)->execute(_execute_cmd_);
#endif // !executeCommandEnd


#ifndef TreeType
enum _tree_type {
	//Property
	TypeModel = 1,
	TypeModelRoot,
	TypePart,
	TypePartRoot,
	TypeMesh,
	TypeMeshRoot,
	TypeMaterial,
	TypeMaterialRoot,
	TypeSection,
	TypeSectionRoot,
	TypeSet,
	TypeSetRoot,
	TypeAssembly,
	TypeAssemblyRoot,
	TypeStep,
	TypeStepRoot,
	TypeLoad,
	TypeLoadRoot,
	TypeBc,
	TypeBcRoot,
	TypeFile,
	TypeFileRoot,
	//Meta
	TypeMeta,
	TypeNode,
	TypeNodeRoot,
	TypeElement,
	TypeElementRoot,
	TypeEdge,
	TypeEdgeRoot,
	TypeSurface,
	TypeSurfaceRoot,
	//Other
	TypeOther,
	TypeOtherRoot,
	//Root
	TypeRoot,

} ;
#define TreeType _tree_type
#endif // !TreeType

#ifndef TreeField
typedef enum {
	FieldRemovable = 101,		/*1-Removable, 0-UnRemovable*/
	FieldHighlight,						/*1-Highlightable, 0-UnHighlightable*/
	FieldType,							/*TreeType*/
} _tree_field;
#define TreeField _tree_field
#endif // !TreeField







